#include "Maxieye_Spi_Mediator_Contre/Maxieye_Mediator_contre.h"


Maxieye_Mediator_Contre::Maxieye_Mediator_Contre()
    : its_mcu_2_soc_data_buffer_cf(CF_DATA_SIZE), its_soc_2_mcu_data_buffer_cf(CF_DATA_SIZE)
    , its_mcu_2_soc_data_buffer_df(DF_DATA_SIZE), its_soc_2_mcu_data_buffer_df(DF_DATA_SIZE)
{

}

Maxieye_Mediator_Contre::~Maxieye_Mediator_Contre()
{

}

Soc_In_Data_Buffer* Maxieye_Mediator_Contre::register_in_buffer(const std::string& unique_id, const Buffer_Id& id, const uint16_t& start_position, const size_t& length)
{
    switch (id)
    {
    case Buffer_Id::SOC_IN_CF:
    {
        if(its_mcu_2_soc_data_buffer_cf.vaild_and_set(unique_id, start_position, length))
        {
            return &its_mcu_2_soc_data_buffer_cf;
        }
        break;
    }

    case Buffer_Id::SOC_IN_DF:
    {
        if(its_mcu_2_soc_data_buffer_df.vaild_and_set(unique_id, start_position, length))
        {
            return &its_mcu_2_soc_data_buffer_df;
        }
        break;
    }
    
    default:
        break;
    }
    return nullptr;
}

Soc_Out_Data_Buffer* Maxieye_Mediator_Contre::register_out_buffer(const std::string& unique_id, const Buffer_Id& id, const uint16_t& start_position, const size_t& length)
{
    switch (id)
    {
    case Buffer_Id::SOC_OUT_CF:
    {
        if(its_soc_2_mcu_data_buffer_cf.vaild_and_set(unique_id, start_position, length))
        {
            return &its_soc_2_mcu_data_buffer_cf;
        }
        break;
    }

    case Buffer_Id::SOC_OUT_DF:
    {
        if(its_soc_2_mcu_data_buffer_df.vaild_and_set(unique_id, start_position, length))
        {
            return &its_soc_2_mcu_data_buffer_df;
        }
        break;
    }
    
    default:
        break;
    }
    return nullptr;
}

Soc_In_Data_Buffer* Maxieye_Mediator_Contre::register_whole_in_buffer(const Buffer_Id& id)
{
    switch (id)
    {
    case Buffer_Id::SOC_IN_CF:
    {
        return &its_mcu_2_soc_data_buffer_cf;
    }

    case Buffer_Id::SOC_IN_DF:
    {
        return &its_mcu_2_soc_data_buffer_df;
    }
    
    default:
        break;
    }
    return nullptr;
}

Soc_Out_Data_Buffer* Maxieye_Mediator_Contre::register_whole_out_buffer(const Buffer_Id& id)
{
    switch (id)
    {
    case Buffer_Id::SOC_OUT_CF:
    {
        return &its_soc_2_mcu_data_buffer_cf;
    }

    case Buffer_Id::SOC_OUT_DF:
    {
        return &its_soc_2_mcu_data_buffer_df;
    }
    
    default:
        break;
    }
    return nullptr;
}